// page/component/details/details.js
Page({
  data:{
    goods: {
      id: 1,
      shopName:"盛亚福源自营旗舰店",
      title: '盛亚福源 牛肉黄金烤肠 500g',
      detail: '满99包邮 正品清真肠，德国工艺，制作考究，使用清真牛肉精心制作而成，体会异域风味，追求品质生活。',
      price: "24.50",
      parameter: '125g/个',
      Stock:"265",
      Sale:365,
      image: 'http://img.ehalfresh.com/ejsimage/images/seller/17/dcd34ae0-0e98-426a-9597-fad62b0b6435.jpg'
    },
    describe:[
      "http://img.ehalfresh.com/ejsimage/images/seller/17/76101498622638083.jpg",
      "http://img.ehalfresh.com/ejsimage/images/seller/17/76461498622645110.jpg",
      "http://img.ehalfresh.com/ejsimage/images/seller/17/43541498622653389.jpg",
      "http://img.ehalfresh.com/ejsimage/images/seller/17/42271498622659955.jpg",
      "http://img.ehalfresh.com/ejsimage/images/seller/17/95681498622662628.jpg"
    ],
    addCardArr:[2,4,6,7,89],
    num: 1,
    totalNum: 0,
    hasCarts: false,
    // curIndex: 0,
    show: false,
    scaleCart: false
  },

  addCount() {
    let num = this.data.num;
    num++;
    this.setData({
      num : num
    })
  },

  addToCart() {
    const self = this;
    const num = this.data.num;
    let total = this.data.totalNum;

    self.setData({
      show: true
    })
    setTimeout( function() {
      self.setData({
        show: false,
        scaleCart : true
      })
      setTimeout( function() {
        self.setData({
          scaleCart: false,
          hasCarts : true,
          totalNum: num + total
        })
      }, 200)
    }, 300)

  },
  urlCart(){
    console.log("6666")
    wx.switchTab({
      url: '../cart/cart'
    })
  },
  addCart(){
    // console.log("333")
    // console.log(this.addCardArr)
    wx.scanCode({
      success: (res) => {
        console.log(res)
        result
      }
    })
  },

  //转发页面（分享）
  onShareAppMessage: function (res) {
    if (res.from === 'button') {
      // 来自页面内转发按钮
      console.log(res.target)
    }
    return {
      title: '伊鲜网',
      path: '/page/user?id=123',
      success: function (res) {
        // 转发成功
      },
      fail: function (res) {
        // 转发失败
      }
    }
  }
})